<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>注册</title>
    <link rel="stylesheet" type="text/css" href="/css/aui.css" />
    <link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="/css/aui-win.css" />
    <style>
			.area {
				margin: 20px auto 0px auto;
			}
			.mui-input-group {
				margin-top: 10px;
			}
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			.mui-input-group label {
				width: 30%;
			}
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 70%;
			}
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			.mui-content-padded {
				margin-top: 25px;
			}
			.mui-btn {
				padding: 10px;
			}
			.link-area {
				display: block;
				margin-top: 25px;
				text-align: center;
			}
			.spliter {
				color: #bbb;
				padding: 0px 8px;
			}
			.oauth-area {
				position: absolute;
				bottom: 20px;
				left: 0px;
				text-align: center;
				width: 100%;
				padding: 0px;
				margin: 0px;
			}
			.oauth-area .oauth-btn {
				display: inline-block;
				width: 50px;
				height: 50px;
				background-size: 30px 30px;
				background-position: center center;
				background-repeat: no-repeat;
				margin: 0px 20px;
				/*-webkit-filter: grayscale(100%); */

				border: solid 1px #ddd;
				border-radius: 25px;
			}
			.oauth-area .oauth-btn:active {
				border: solid 1px #aaa;
			}
      .mui-input-row .arr{
        float: right;
        font-size: 15px;
        border: 1px solid #ddd;
        border-radius: 15px;
        background: #fff;
      }
      .mui-input-row .err{
        padding-left: 15px;
      }

		</style>
<body>
  <header class="mui-bar mui-bar-nav">
    <h1 class="mui-title">注册</h1>
  </header>
  <div class="mui-content">
    <form id='login-form' class="mui-input-group">
      <div class="mui-input-row">

        <input id='account' type="text" class="mui-input-clear mui-input" placeholder="手机号">
      </div>
      <div class="mui-input-row">

        <input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
      </div>
      <div class="mui-input-row">

        <input id='userPwd2' type="password" class="mui-input-clear mui-input" placeholder="确认密码">
      </div>
      <div class="mui-input-row">
        <label class="arr" id='get_sns' tapmode onclick="getVerify()"><input type="button" disabled style="border:none;"  value="获取验证码"/></label>
        <input id='code' type="number" class="err" placeholder="请输入收到的验证码">
      </div>

    </form>
    <div class="mui-content-padded">
      <button class="mui-btn mui-btn-block mui-btn-primary" tapmode onclick="register()">注册</button>
    </div>
    <script type="text/javascript" src="../script/api.js" ></script>
    <script type="text/javascript" src="./conf/config.js"></script>
    <script type="text/javascript" src="./js/common.js"></script>
    <script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
    <!-- <script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script> -->
<script type="text/javascript">
apiready = function() {


        };
        //获取验证码
        function getVerify() {
          var phone = $api.byId('account').value;
          if(phone != ''){
          $("#get_sns").css({background:"#cccccc",color:"#fff"}).html('正在发送...');
            api.ajax({
                url: SITE_URL+'index.php?m=api&c=appp&a=send_phcode',
                method: 'GET',
                data : { values:{"phone":phone}}
            }, function(ret, err) {
              if (ret.status==1) {
                $("#get_sns").css({background:"#cccccc",color:"#fff"}).html('发送成功...');
          }
        });
      }else{
              alert('请填写手机号');
          }

}
//注册
function register() {
    var phone = $api.byId('account').value;
    var pword = $api.byId('password').value;
    var pword1 = $api.byId('userPwd2').value;
    var code = $api.byId('code').value;
  if (phone == '') {
  		alert('请填写手机号');
  		return false;
  	};
  if (pword == '') {
    	alert('请填写密码');
    	return false;
    };
  if (pword1 == '') {
      alert('请填写确认密码');
      return false;
    };
  if (pword != pword1) {
      alert('两次密码请填写一致');
      return false;
    };
  if (code == '' || code != '') {
    api.ajax({
        url: SITE_URL+'index.php?m=api&c=appp&a=register_check_sms',
        method: 'GET',
        data : { values:{"phone":phone,"code":code}}

    }, function(ret, err) {
      if (ret.status==0) {
        api.alert({
            msg: '手机号码为空或格式错误或验证码为空'
          });
  }else{
    api.ajax({
        url: SITE_URL+'index.php?m=api&c=appp&a=register',
        method: 'GET',
        data : { values:{"phone":phone,"pword":pword,"pword1":pword1,"code":code}}
    }, function(ret, err) {
      if (ret.status==0) {
        api.alert({
            msg: '注册失败'
            //  msg: JSON.stringify(ret)
          });
  }else{
    api.openWin({
              name: 'login',
              url: './login.html',
              pageParam: {
                  name: 'test'
              }
            });
  }
});
  }
});
    }
  }



</script>


</body>
</html>
